package com.cn.news.service.impl;

import com.cn.common.pojo.NItemModel;
import com.cn.common.pojo.ResultModel;
import com.cn.news.mapper.NitemDao;
import com.cn.news.service.NitemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NitemServiceImpl implements NitemService {
    @Autowired
    NitemDao nitemDao;
    @Override
    public ResultModel nitem() {
        return ResultModel.getResultModel("success",0,1,nitemDao.nitem());
    }

    @Override
    public ResultModel delete(int id) {
        int delete = nitemDao.delete(id);
        return ResultModel.getResultModelByCount(delete);
    }

    @Override
    public ResultModel update(NItemModel nItemModel) {
        return ResultModel.getResultModelByCount(nitemDao.update(nItemModel));
    }

    @Override
    public ResultModel insert(NItemModel nItemModel) {
        return ResultModel.getResultModelByCount(nitemDao.insert(nItemModel));
    }

    @Override
    public ResultModel enable(int id) {
        return ResultModel.getResultModelByCount(nitemDao.enable(id));
    }

    @Override
    public ResultModel findById(int id) {
        return ResultModel.getResultModelByAll(nitemDao.findById(id),1);
    }

    @Override
    public ResultModel limit(NItemModel nItemModel) {
        return ResultModel.getResultModel("",0,1,nitemDao.limit(nItemModel));
    }
}
